<!DOCTYPE html>

<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>结构伪类</title>
    <style type="text/css">
        .wrapper {
            width: 80%;
            border: 1px solid blue;
            margin: 25px auto;
        }
        
        .wrapper>* {
            height: 50px;
            border: 1px solid green;
            margin: 15px;
        }
        
        .first p:only-child {
            background: #9696ff;
        }
        
        .second p:only-child {
            background: #9696ff;
        }
        
        .third p:only-of-type {
            background: #ff0;
        }
        
        .third div:only-of-type {
            background: #dedede;
        }
    </style>
</head>

<body>

    <div class="wrapper first">
        <p>:only-child</p>
    </div>

    <div class="wrapper second">
        <p></p>
        <p></p>
        <p></p>
    </div>

    <hr>

    <div class="wrapper third">
        <div></div>
        <p>only-of-type</p>
        <div></div>
    </div>



</body>

</html>